/**
 * 生成图片验证码
 * @return 图片
 * @return 验证码
 */
const router=require('express').Router();
const svgCaptcha =require('svg-captcha');
const {Ajax, enu} = require("../utils/Ajax");

let code;

router.get('/getCode',(req,res)=>{
    const CodeImage=svgCaptcha.create({
        size:4,
        ignoreChars:'0o1l',
        color:true,
        noise:3,
        background:'#666'
    })
    code=CodeImage.text
    res.send(Ajax(enu().code.service.success,'获取验证码成功!',CodeImage.data))
})

const GetCode=()=>{
    return {code:code}
}


module.exports= {router,GetCode}